package com.fh.module_main.adapter

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.fh.module_main.R
import com.fh.lib_base.data.bean.CityBean

/**
 * 热门城市流式布局适配器
 */
class HotListFlowRecyclerAdapter(data: ArrayList<CityBean>?) :
    BaseQuickAdapter<CityBean, BaseViewHolder>(R.layout.main_flow_layout, data) {

    private lateinit var itemClickListener: ItemClickListener

    override fun convert(holder: BaseViewHolder, item: CityBean) {
        holder.setText(R.id.flow_tag,item.name)
        holder.itemView.setOnClickListener {
            itemClickListener.onClick(data.indexOf(item))
        }
    }

//    override fun onBindViewHolder(holder: BaseViewHolder, position: Int) {
////        super.onBindViewHolder(holder, position)
//        holder.itemView.setOnClickListener {
//            itemClickListener.onClick(position)
//        }
//    }

    //回调方式 设置点击事件
    interface ItemClickListener{
        fun onClick(pos: Int)
    }
    fun setOnItemClickListener(itemClickListener: ItemClickListener){
        this.itemClickListener = itemClickListener;
    }
}